package com.hb.config;

import com.hb.impl.Cake;
import com.hb.impl.Cookies;
import com.hb.impl.IceCream;
import com.hb.impl.Popsicle;
import com.hb.interfaces.Dessert;
import com.hb.qualifiers.Cold;
import com.hb.qualifiers.Creamy;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class UniqueConfig {
    @Bean
    // @Qualifier 可以与 @Bean 注解一起使用
    @Qualifier("circle")
    public Dessert cake() {
        return new Cake();
    }

    @Bean
    @Qualifier("sweet")
    public Dessert cookies() {
        return new Cookies();
    }

    @Bean
    // 不仅能跟 @Component 注解一起使用，也能与 @Bean 注解一起使用
    @Primary
    public Dessert iceCream() {
        return new IceCream();
    }

    @Bean
    @Cold
    @Creamy
    public Popsicle popsicle() {
        return new Popsicle();
    }
}
